Skip to content

feat: option to force disable persisted operations#2007

Merged
endigma merged 4 commits intomainfrom
jesse/eng-7462-option-to-disable-po
Jul 4, 2025
Merged

feat: option to force disable persisted operations#2007
endigma merged 4 commits intomainfrom
jesse/eng-7462-option-to-disable-po

Conversation

@endigma
Copy link
Copy Markdown
Member

@endigma endigma commented Jul 2, 2025

Summary by CodeRabbit

  • New Features

    • Added a configuration option to disable persisted operations. When disabled, all requests using persisted operations will be blocked with an appropriate response.
    • Updated configuration files and schema to support the new disable option for persisted operations.
  • Bug Fixes

    • Improved consistency in configuration environment variable naming for persisted operations.
  • Chores

    • Minor formatting update to configuration files for consistency.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 2, 2025

Walkthrough

A new configuration option to disable persisted operations was introduced across the codebase. This includes adding a Disabled field to persisted operations configuration structs and schemas, updating environment variable mappings, and propagating the new field through constructors and logic. Internal struct field names were also standardized to lowercase, and a guard was added to block persisted operations when disabled.

Changes

Files/Groups Change Summary
router/core/graph_server.go Added assignment of PersistedOperationsDisabled from config to OperationBlockerOptions in buildGraphMux.
router/core/graphql_prehandler.go Renamed operationBlocker fields to lowercase; added check to block persisted operations if disabled.
router/core/operation_blocker.go Added persistedOperationsDisabled, safelistEnabled, logUnknownOperationsEnabled fields; updated constructor and options struct.
router/pkg/config/config.go Added Disabled field to PersistedOperationsConfig; updated env var tags and prefixes; added envPrefix to config struct.
router/pkg/config/config.schema.json Added disabled boolean property to persisted_operations object in schema.
router/pkg/config/testdata/config_defaults.json,
router/pkg/config/testdata/config_full.json
Added "Disabled": false to "PersistedOperationsConfig" in both config testdata files.
router/debug.config.yaml Added a newline at the end of the file.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52fb144 and 4b8601d.

📒 Files selected for processing (8)
  • router/core/graph_server.go (1 hunks)
  • router/core/graphql_prehandler.go (4 hunks)
  • router/core/operation_blocker.go (3 hunks)
  • router/debug.config.yaml (1 hunks)
  • router/pkg/config/config.go (2 hunks)
  • router/pkg/config/config.schema.json (1 hunks)
  • router/pkg/config/testdata/config_defaults.json (1 hunks)
  • router/pkg/config/testdata/config_full.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • router/debug.config.yaml
  • router/pkg/config/testdata/config_defaults.json
  • router/pkg/config/testdata/config_full.json
  • router/core/graph_server.go
  • router/pkg/config/config.schema.json
  • router/core/graphql_prehandler.go
  • router/core/operation_blocker.go
  • router/pkg/config/config.go
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build-router
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_test
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added the router label Jul 2, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 2, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-ef1e3e7156d28175932bce13a7b55d3a8f271862

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
router/pkg/config/config.schema.json (1)

146-150: Align boolean‐field defaults within persisted_operations

disabled explicitly sets "default": false, while neighbouring booleans such as safelist.enabled and log_unknown omit a default (implicitly false). Consider either:

  1. Dropping the redundant default here, or
  2. Adding "default": false to the other boolean siblings

to keep the schema style consistent and avoid signalling an unintended semantic difference.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd9ddb2 and f0469f7.

📒 Files selected for processing (8)
  • router/core/graph_server.go (1 hunks)
  • router/core/graphql_prehandler.go (4 hunks)
  • router/core/operation_blocker.go (3 hunks)
  • router/debug.config.yaml (1 hunks)
  • router/pkg/config/config.go (2 hunks)
  • router/pkg/config/config.schema.json (1 hunks)
  • router/pkg/config/testdata/config_defaults.json (1 hunks)
  • router/pkg/config/testdata/config_full.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
router/pkg/config/config.schema.json (1)

undefined

<retrieved_learning>
Learnt from: SkArchon
PR: #1929
File: router/internal/circuit/manager.go:16-25
Timestamp: 2025-06-30T20:39:02.376Z
Learning: In the Cosmo router project, parameter validation for circuit breaker configuration is handled at the JSON schema level rather than through runtime validation methods on structs. The config.schema.json file contains comprehensive validation constraints for circuit breaker parameters.
</retrieved_learning>

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build-router
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: image_scan
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (15)
router/debug.config.yaml (1)

42-43: LGTM! Minor formatting improvement.

Adding a trailing newline follows POSIX text file standards and improves code formatting consistency.

router/pkg/config/testdata/config_defaults.json (1)

422-422: LGTM! Proper addition of the disabled flag.

The new Disabled field correctly defaults to false, ensuring backwards compatibility while enabling the new feature to disable persisted operations.

router/core/graph_server.go (1)

1209-1209: LGTM! Proper configuration propagation.

The PersistedOperationsDisabled field correctly propagates the configuration setting from persistedOperationsConfig.Disabled to the OperationBlockerOptions, enabling the operation blocker to respect the new disabled flag.

router/pkg/config/testdata/config_full.json (1)

781-781: LGTM! Consistent test data update.

The addition of the Disabled field maintains consistency with the config_defaults.json file, ensuring comprehensive test coverage for the new persisted operations configuration option.

router/pkg/config/config.go (3)

801-801: LGTM! New disabled field implementation is correct.

The addition of the Disabled field with proper environment variable mapping and default value follows the established pattern in the codebase.


998-998: Good architectural improvement with envPrefix.

The addition of envPrefix:"PERSISTED_OPERATIONS_" provides a cleaner environment variable structure and explains the simplified tags in the nested struct fields.


802-803: Ensure backward-compatibility of renamed environment variables

We’ve simplified the tags on PersistedOperationsConfig so that:

  • LogUnknown now only reads LOG_UNKNOWN (was PERSISTED_OPERATIONS_LOG_UNKNOWN)
  • Safelist now uses its own envPrefix:"SAFELIST_" (was PERSISTED_OPERATIONS_SAFELIST_)

Without fallback tags or a migration guide, existing deployments that set PERSISTED_OPERATIONS_LOG_UNKNOWN or PERSISTED_OPERATIONS_SAFELIST_* will no longer work. Please:

• Confirm whether your config loader still recognizes the old PERSISTED_OPERATIONS_* names or add explicit fallbacks (e.g. env:"PERSISTED_OPERATIONS_LOG_UNKNOWN;LOG_UNKNOWN")
• Update your documentation/CHANGELOG to list the old→new variable mappings and any required migration steps

Locations to review:

  • router/pkg/config/config.go:802–803 (LogUnknown, Safelist)
  • router/pkg/config/config.go:998 (the envPrefix:"PERSISTED_OPERATIONS_" on PersistedOperationsConfig)
router/core/operation_blocker.go (4)

6-6: Minor: Import reordering is acceptable.

The "reflect" import was moved earlier in the import list, which doesn't affect functionality.


27-29: Excellent encapsulation improvement.

Converting the exported fields to unexported (SafelistEnabledsafelistEnabled, LogUnknownOperationsEnabledlogUnknownOperationsEnabled) and adding persistedOperationsDisabled improves the API design by preventing external modification of internal state.


56-56: LGTM! New option field follows established pattern.

The PersistedOperationsDisabled field in OperationBlockerOptions properly supports the new functionality.


67-69: Constructor properly initializes new fields.

The initialization of the new unexported fields from the options struct is correctly implemented and maintains consistency with the existing pattern.

router/core/graphql_prehandler.go (4)

482-482: LGTM! Consistent with encapsulation improvements.

The field access update to use the unexported safelistEnabled field is consistent with the refactoring in operation_blocker.go.


489-489: Field access updates are correct.

Both safelistEnabled and logUnknownOperationsEnabled field accesses have been properly updated to use the new unexported fields.


542-542: Consistent field access pattern maintained.

Another correct update to use the unexported field, maintaining consistency across the codebase.


584-584: Field access updates maintain consistency.

The updates to use logUnknownOperationsEnabled and safelistEnabled are correctly implemented and consistent with the encapsulation improvements.

Also applies to: 586-586

Comment thread router/core/graphql_prehandler.go
Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread router/pkg/config/config.schema.json
Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@endigma endigma force-pushed the jesse/eng-7462-option-to-disable-po branch from 52fb144 to 4b8601d Compare July 4, 2025 09:01
@endigma endigma merged commit 68db6bb into main Jul 4, 2025
30 of 31 checks passed
@endigma endigma deleted the jesse/eng-7462-option-to-disable-po branch July 4, 2025 09:47
yuzoonc1 pushed a commit to yuzoonc1/cosmo that referenced this pull request Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants